<?php

namespace App\Filament\Resources\Admin\Roles;

use App\Enums\NavigationGroup;
use App\Filament\Resources\Admin\Roles\Pages\ListAdminRoles;
use App\Filament\Resources\Admin\Roles\Pages\RolePermission;
use App\Filament\Resources\Admin\Roles\Tables\AdminRolesTable;
use App\Models\Admin\AdminRole;
use Filament\Resources\Resource;
use Filament\Tables\Table;

class RoleResource extends Resource
{
    protected static ?string $model = AdminRole::class;

    public static string|null|\UnitEnum $navigationGroup = NavigationGroup::Permissions;

    public static ?string $navigationLabel = '角色管理';

    protected static ?int $navigationSort = 20;

    protected static ?string $modelLabel = '角色';

    public static function table(Table $table): Table
    {
        return AdminRolesTable::configure($table);
    }

    public static function shouldRegisterNavigation(): bool
    {
        return auth()->user()->can('admin.role.list');
    }

    public static function getPages(): array
    {
        return [
            'index' => ListAdminRoles::route('/'),
            'permission' => RolePermission::route('/{id}/permission'),
        ];
    }
}
